{% load i18n mezzanine_tags comment_tags rating_tags %}
{% for comment in comments_for_thread %}
    <li class="D_photoGallery_comment">
        {% if not comment.is_removed and comment.is_public or request.user.is_staff %}
            <div class="commentMemberPhoto">
                <img class="pull-left media-object"
                     src="{{ MEDIA_URL }}{% thumbnail comment.user.account.head 50 50 %}">
            </div>
            <div class="commentContent">
            <span class="commentAuthor">
                <a href="{% url 'profile' comment.user.username %}"
                   class="commentAuthorAnchor">{{ comment.user.account.get_name }}</a>
            </span>
            <span class="commentMetadata"> 发表于 {% blocktrans with sometime=comment.submit_date|timesince %}
                {{ sometime }} 以前{% endblocktrans %}</span>
            <p class="commentText">{{ comment.comment|comment_filter }}</p>
        {% endif %}
        {% if not comment.is_removed and comment.is_public %}
            <a href="#reply-{{ comment.id }}" class="reply">
                <span class="glyphicon glyphicon-share-alt"></span> {% trans "Reply" %}
            </a>
            <form class="comment-reply-form" method="post" id="reply-{{ comment.id }}"
                  action="{{ comment_url }}#reply-{{ comment.id }}"
                  {% if replied_to != comment.id %}style="display:none;"{% endif %}>
                {% csrf_token %}

                {{ posted_comment_form.timestamp }}
                {{ posted_comment_form.security_hash }}
                {{ posted_comment_form.object_pk }}
                {{ posted_comment_form.content_type }}

                {% if not request.POST.replied_to %}
                    {{ posted_comment_form.comment }}
                    {{ posted_comment_form.timestamp }}
                    {{ posted_comment_form.security_hash }}

                    {{ posted_comment_form.name }}
                    {{ posted_comment_form.email }}

                {% else %}
                    {% fields_for unposted_comment_form %}
                {% endif %}
                <input type="hidden" name="replied_to" value="{{ comment.id }}">

                <div class="form-actions">
                    <input class="D_submit btn btn-primary btn-lg" type="button" value="{% trans "Reply" %}">
                </div>
            </form>

        {% else %}
            <p>
                {% if comment.is_removed %}
                    <span class="glyphicon glyphicon-remove-circle"></span> {% trans "Comment deleted" %}
                {% else %}
                    <span class="glyphicon glyphicon-warning-sign"></span> {% trans "Comment awaiting approval" %}
                {% endif %}
                <small class="timespan">
                    {% blocktrans with sometime=comment.submit_date|timesince %}{{ sometime }}以前{% endblocktrans %}
                </small>
            </p>
        {% endif %}
        <div class="reply_comment">
            <ul class="group-activity">
                {% comment_thread comment %}
            </ul>
        </div>
    </li>
{% endfor %}
{% if no_comments %}
    <p>{% trans "There are currently no comments" %}</p>

{% endif %}
<script>
    $(function () {
        $(".reply_comment").find(".commentContent").css("width", "29em");
        $(".reply_comment").find(".group-activity").css("padding-left", "0em");
    });
</script>